﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using SpriteGame.UI;
using SpriteGame.Helpers;
using Microsoft.Xna.Framework.Input;
using FarseerPhysics.Dynamics;
using SpriteGame.Entities;
using FarseerPhysics.DebugViewXNA;
using SpriteGame.Effects.Blood;
using SpriteGame.Effects.Particles;
using SpriteGame.Rendering;

namespace SpriteGame.Scenes
{
    class ShooterGame:Scene
    {
        public ShooterGame(Game1 _parent)
            : base(_parent)
        {
        }

        public override void BuildHUD()
        {
            base.BuildHUD();
        }

        CharacterActor player;

        public override void LoadContent()
        {
            base.LoadContent();

            //LoadScene("ZombieScene");

            DebugViewXNA debugView = new DebugViewXNA(World);
            DebugViewXNA.LoadContent(parent.GraphicsDevice, content);

            AddEntity(new BaseSprite(this, BodyType.Static, Vector2.UnitY * -15, 0.0f, 100.0f, "Textures/Tiles_Long"));
            player = new CharacterActor(this, BodyType.Dynamic, Vector2.UnitY * 30, 0.0f, "Textures/SpriteAnimations/Abe/WalkSpriteSheet");
            AddEntity(player);
        }

        public override void Update(GameTime _time)
        {
            base.Update(_time);

            parent.LerpCamera(player.Position, 0.2f);
                        //Vector2 midVector = new Vector2(0, 20);

            //Random r = new Random();
            //for (int i = 0; i < 10; i++)
            //{
            //    Vector2 vV = new Vector2((1 - (float)r.NextDouble()), ((float)r.NextDouble() * 3)) * 0.07f;
            //    /BloodParticleManager.Instance.SpawnParticle(Vector2.Zero, vV, (float)r.NextDouble() * 0.01f);
            //    ParticleManager.Instance.SpawnParticle(player.Position, vV, TextureLibrary.GetTexture("Textures/Particles/WhiteDot"), Color.White);
            //}
            //InputHandler.UpdateInput();
            Vector2 worldMousePos = parent.ConvertScreenToWorld((int)InputHandler.MousePosition.X, (int)InputHandler.MousePosition.Y);
            if (InputHandler.LeftClick())
            {
                AddEntity(new BaseSprite(this, BodyType.Dynamic,worldMousePos , 0.0f, "Textures/Tile"));
            }
            if (InputHandler.RightClick())
            {
                AddEntity(new GravityBall(this, 2, 2, BodyType.Dynamic, worldMousePos, 0.0f, "Textures/Tile"));
            }
        }

        public override void Draw(GameTime _time)
        {
            base.Draw(_time);

            //Matrix proje = parent.Projection;
            //DebugViewXNA.Instance.RenderDebugData(ref proje);
        }
    }
}
